package spacewar2.objects;

import spacewar2.powerups.SpacewarPowerupEnum;
import spacewar2.shadows.BulletShadow;
import spacewar2.utilities.Position;
import spacewar2.utilities.Vector2D;

public class Bullet extends SpacewarWeapon {
	public static int BULLET_DAMAGE = -200;
	public static int BULLET_COST = -50;
	public static int BULLET_RADIUS = 3;
	public static int BULLET_MASS = 5;
	public static int INITIAL_VELOCITY = 100;
	
	/**
	 * A new bullet with the specified position and shift
	 */
	public Bullet(Position position, Ship firingShip) {
		super(BULLET_MASS, BULLET_RADIUS, position, BULLET_DAMAGE, BULLET_COST,firingShip);
		int radiusToShift = firingShip.getRadius() + BULLET_RADIUS * 2;
		position.setX(position.getX() + (radiusToShift * Math.cos(position.getOrientation())));
		position.setY(position.getY() + (radiusToShift * Math.sin(position.getOrientation())));
		Vector2D newVelocity = new Vector2D(INITIAL_VELOCITY * Math.cos(position.getOrientation()), INITIAL_VELOCITY * Math.sin(position.getOrientation()));
		position.setTranslationalVelocity(newVelocity);
		shadow = new BulletShadow(this);
		setDrawable(true);
		setAlive(true);
		this.isControllable = false;
		this.isMoveable = true;
	}

	/**
	 * Copy the bullet
	 */
	public Bullet deepClone() {
		Bullet newBullet = new Bullet(position.deepCopy(), firingShip.deepClone());
		newBullet.setAlive(isAlive);
		newBullet.id = id;
		return newBullet;
	}

	/**
	 * Bullets do not respawn
	 */
	public boolean canRespawn() {
		return false;
	}

	/**
	 * Mostly a placeholder for when power ups work
	 */
	public SpacewarPowerupEnum getType() {
		return SpacewarPowerupEnum.FIRE_MISSLE;
	}


}
